#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QTimerEvent>
#include <QLCDNumber>
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    // 启动定时
    timer_id1 = startTimer(1000);
    timer_id2 = startTimer(2000);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::timerEvent(QTimerEvent *event)
{
    if(event->timerId() == timer_id1)
    {
        int value = ui->lcdNumber_1->value();
        ui->lcdNumber_1->display(QString::number(value+1));
    }
    if(event->timerId() == timer_id2)
    {
        int value = ui->lcdNumber_2->value();
        ui->lcdNumber_2->display(QString::number(value+1));
    }
}

